/**
 * Copyright 2004 Cordys R&D B.V. 
 * 
 * This file is part of the Cordys FTP Connector. 
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
 package com.eibus.applicationconnector.ftp;

import com.eibus.applicationconnector.ftp.Append;
import com.eibus.applicationconnector.ftp.Delete;
import com.eibus.applicationconnector.ftp.DeleteFiles;
import com.eibus.applicationconnector.ftp.DownLoad;
import com.eibus.applicationconnector.ftp.FTPCommand;
import com.eibus.applicationconnector.ftp.GetListOfFiles;
import com.eibus.applicationconnector.ftp.ListDirectories;
import com.eibus.applicationconnector.ftp.PrintWorkingDirectory;
import com.eibus.applicationconnector.ftp.RemoveDirectory;
import com.eibus.applicationconnector.ftp.Rename;
import com.eibus.applicationconnector.ftp.UpLoad;

/**
 * This is a Simple Factory Pattern that decides which class's object
 * to return based on the command that is passed to the getHandler()
 * method.  
 */
class CommandFactory
{
	/*
	 * Make the constructor private to avoid other classes
	 * to directly create an instance of this class
	 */
	private CommandFactory()
	{
		
	}
	
	/**
	 * This  method returns an instance of one of the class that handles
	 * the incoming soap method
	 * 
	 * @param command
	 * @return an object of one of the SOAP method handler
	 */
    public static FTPCommand getHandler(String command)
    {
    	FTPCommand ftpCommandHandler = null;
    	
        if(command.equals("download") || command.equals("multipleDownload"))
        {
            ftpCommandHandler  = new DownLoad();
	    }
    	else if(command.equals("upload")  || command.equals("multipleUpload"))
        {
            ftpCommandHandler = new UpLoad();
		}
        else if(command.equals("getListOfFiles"))
		{
			ftpCommandHandler = new GetListOfFiles();
		}
		else if(command.equals("printDir"))
		{
			ftpCommandHandler = new PrintWorkingDirectory();
		}
		else if(command.equals("rename"))
		{
			ftpCommandHandler = new Rename();
		}
		else if(command.equals("delete"))
		{
			ftpCommandHandler = new Delete();
		}
		else if(command.equals("removeDir"))
		{
			ftpCommandHandler = new RemoveDirectory();
		}
        else if(command.equals("deleteFiles"))
		{
			ftpCommandHandler = new DeleteFiles();
		}
        else if(command.equals("listDirectories"))
		{
			ftpCommandHandler = new ListDirectories();
		}
		else if(command.equals("append"))
		{
			ftpCommandHandler = new Append();
		}
		else if(command.equals("createDirectory"))
		{
			ftpCommandHandler = new CreateDirectory();
		}
		
    	return ftpCommandHandler; 
    }
}